#include <Arduino_APDS9960.h>

void setup() {
	Serial.begin(9600);
	while (!Serial);

	if (!APDS.begin()) {
		Serial.println("Error initializing APDS-9960 sensor.");
	}
}

void loop() {
	// Check if a proximity reading is available.
	if (APDS.proximityAvailable()) {
		// Read the proximity where:
		// - 0	 => close
		// - 255 => far
		// - -1	=> error
		int proximity = APDS.readProximity();

		// Print value to the Serial Monitor.
		Serial.println(proximity);
	}

	// Wait a bit before reading again.
	delay(100);
}
